package cn.wolfcode.wolf2w.member.listener;

import cn.wolfcode.wolf2w.member.api.domain.UserFoandfan;
import cn.wolfcode.wolf2w.member.service.IUserFoandfanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RedisMenberDataInitListener implements ApplicationListener<ContextStartedEvent> {
    @Autowired
    private IUserFoandfanService userFoandfanService;

    @Override
    public void onApplicationEvent(ContextStartedEvent event) {
        System.out.println("--------------------------redis数据初始化-begin--------------------------");
        List<UserFoandfan> list = userFoandfanService.list();
        for (UserFoandfan uf : list) {
            userFoandfanService.initStrategyHash(uf.getUid());
        }
        System.out.println("--------------------------redis数据初始化-end--------------------------");

    }
}
